package com.ghbank.rdws.management.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ghbank.rdws.management.service.ConfigService;
import com.ghbank.rdws.common.http.RichResponseEntity;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping(value = "/config")
@Slf4j
public class ConfigController {
    
    @Autowired
    private ConfigService configService;
    
    @PostMapping(value = "/changeSysDataSource")
    public RichResponseEntity<String> changeSysDataSource(long id, String url,String username, String password) {
        try {
            configService.changeSysDataSource(id,url,username,password);
            return RichResponseEntity.ok("更新成功");
        } catch (Exception e) {
             log.error(e.getMessage(),e);
             return RichResponseEntity.error(HttpStatus.INTERNAL_SERVER_ERROR,"更新成功");
        }
       
    }
}
